<?php

// Canonical-URLs
//
// Copyright (c) 2009 SILENCE
// http://www.czxqlove.com
//
// Released under the GPL license
// http://www.opensource.org/licenses/gpl-license.php
//
// This is an add-on for WordPress
// http://wordpress.org/
//

/*
Plugin Name: Canonical-URLs
Plugin URI: http://www.czxqlove.com/archives/2009/canonical-urlscanonical-urls.html
Description: To make your URLs be canonical. Easy to use. Supports category page, tag page and single page now, more is coming...
Version: 1.01
Author: SILENCE
Author URI: http://www.czxqlove.com
*/

//Function: load tag in the head
function canonical_urls() {
	$output_urls	=	'';

	if (is_category()) {
		// If this is a category archive
		global $cat;
		$output_urls	=	get_category_link($cat);
	} elseif(is_tag()) {
		// If this is a tag archive
		global $tag_id;
		$output_urls	=	get_tag_link($tag_id);
	} elseif (is_single()) {
		// If this is a single page
		$output_urls	=	get_permalink();
	}

	if($output_urls != '') {
		echo "\n".'<!-- Start Of Canonical-URLs 1.01 -->'."\n";
		echo '<link rel="canonical" href="'.$output_urls.'" />'."\n";
		echo '<!-- End Of Canonical-URLs 1.01 -->'."\n";
	}
}

add_action('wp_head', 'canonical_urls');


//that's all
?>